export default {
  namespaced: true,
  state: {
    id: 0, //用户ID
    is_comp: "", //判断是用户还是企业
    is_perfect: "", //是否完善企业信息
    username: "", // 用户名
    mobile: "", // 手机号
    avatar: "", // 默认头像
    access_token: "", // 令牌
    user_id:"",//uid
    token: "", // 令牌
    user_name:"",
    comp_name:''
  },
  mutations: {
    setUserInfo(state, userinfo) {
      console.log(state,"sssssssssssss");
      for (let i in userinfo) {
        for (let j in state) {
          if (i === j) {
            state[j] = userinfo[i];
          }
        }
      }
	  console.log(1233333333333,state)
      localStorage.setItem("rcjj_userinfo", JSON.stringify(state));
    },
  },
  actions: {
    async login({ state, commit, dispatch, rootState }, data) {
      commit("setUserInfo", data);
      localStorage.setItem("rcjj_userinfo", JSON.stringify(state));
    },
    async logout({ state, rootState }) {
      // 从本地缓存中异步移除指定key
      localStorage.removeItem("rcjj_userinfo");
      store.dispatch("common/init");
    },
  },
};
